package com.fangmao.jetpack.room;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

/**
 * @ProjectName: wman
 * @Package: com.fangmao.jetpack.room
 * @ClassName: WordDatabase
 * @Description: java类作用描述
 * @Author: wman
 * @CreateDate: 2020/1/7 15:35
 * @UpdateUser: 更新者
 * @UpdateDate: 2020/1/7 15:35
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
@Database(entities = {Word.class}, version = 1, exportSchema = false)
public abstract class WordDatabase extends RoomDatabase {
    private static WordDatabase INSTACNE;

    public static synchronized WordDatabase getDatabase(Context context) {
        if (INSTACNE == null) {
            synchronized (WordDatabase.class) {
                if (INSTACNE == null) {
                    INSTACNE = Room.databaseBuilder(context.getApplicationContext(), WordDatabase.class, "word_database")
                            .build();
                }
            }
        }
        return INSTACNE;
    }

    public abstract WordDao getWordDao();
}
